<?php
error_reporting(0);
if($_POST){
	$key=trim($_POST['keyword']);
	$return=array(array('key'=>'','val'=>'搜索后必须请选择物品'));
    $file = fopen("jl.txt", "r");
	if($key==''){
		while(!feof($file))
		{
			$line=fgets($file);
			$txts=explode('|',$line);
			if(count($txts)==2){
				$tmp=array(
				   
				   'key'=>$txts[0],
				   'val'=>$txts[1]
				);
				array_push($return,$tmp);
			}
		}
	}else{
		while(!feof($file))
		{
			$line=fgets($file);
			$pos=strpos($line,$key);
			if($pos){
				$txts=explode('|',$line);
				if(count($txts)==2){
					$tmp=array(
						'key'=>$txts[0],
						'val'=>$txts[1]
					);
					array_push($return,$tmp);
				}
			}
		}		
	}
    fclose($file);
	echo(json_encode($return));
}else{
	$return=array(array('key'=>'','val'=>'请选择'));
	echo(json_encode($return));
}